﻿#region | Copyright © 2556 |

/*
##########################################################################
	Author By : Siriwat Suananpornpanit
	DateTime : 2556/08/30
##########################################################################
*/

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Core;

namespace Web.MasterPage
{
    public partial class Site : System.Web.UI.MasterPage
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            /*
            Core.SessionPool.GetInstance().CheckSession();
             */
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }

        public void OnToggleModal(Core.MessageFlag flag, String massage)
        {
            if (flag != MessageFlag.None){
                Image img = pcValidationScript.FindControl("imgWraning") as Image;
                Literal lit = pcValidationScript.FindControl("litWraningHeader") as Literal;
                // Show result
                if (flag==MessageFlag.Wraning)
                {
                    if (img != null)
                        img.ImageUrl = "~/Images/wraning.png";

                    if (lit != null)
                        lit.Text = Core.ResourceTools.GetResource(
                            resourceKey: "Wraning");
                }
                // Show Alert
                else if (flag == MessageFlag.Completed)
                {
                    if (img != null)
                        img.ImageUrl = "~/Images/check.png";

                    if (lit != null)
                        lit.Text = Core.ResourceTools.GetResource(
                            resourceKey: "Confirm");
                }
                if (!String.IsNullOrEmpty((String)massage))
                {
                    ClientScriptModal.OnLoad(
                        content:(String)massage);

                    Core.Modal.OnControl(
                        page:this.Page, 
                        control: pcValidationScript,
                        modalBox: ModalFlag.Show);
                }
            }
        }

        public void OnException(String massage)
        {

            Image img = pcValidationScript.FindControl("imgWraning") as Image;
            Literal lit = pcValidationScript.FindControl("litWraningHeader") as Literal;

            if (img != null)
                img.ImageUrl = "~/Images/error.png";

            if (lit != null)
                lit.Text = Core.ResourceTools.GetResource(
                    resourceKey: "Error");

            if (!String.IsNullOrEmpty((String)massage))
            {
                ClientScriptModal.OnLoad(
                        content: (String)massage);

                Core.Modal.OnControl(
                    page:this.Page, 
                    control: pcValidationScript,
                    modalBox: ModalFlag.Show);
            }
        }

        /*
        
        */

    }
}